<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
%>
<jsp:include page="../../import.jsp" flush="true" />
<link rel="StyleSheet" href="<%=path%>/lib/dtree/dtree.css" type="text/css" />
<script type="text/javascript" src="<%=path%>/lib/dtree/dtree.js"></script>
<SCRIPT LANGUAGE="JavaScript">
<!--
$(function(){
	$("#editDiv").dialog({
		autoOpen: false,
		bgiframe: true,
		//height: 500,
		width:600,
		modal: true,
		buttons: {
			"提交": function() { 
				//$(this).dialog("close"); 
				_submit();
			}, 
			"取消": function() { 
				$(this).dialog("close"); 
			} 
		}
	});
});

//-->
</SCRIPT>
<body>

<div id="editDiv" title="角色编辑" style="display:none">
	<span align='center'>
		<FORM METHOD='POST' ACTION='<%=path%>/security/roleManage!update.action' onsubmit="return checkData();">
			<INPUT TYPE="hidden" NAME="pid"  id="pid" value=''>
			<INPUT TYPE="hidden" NAME="id"   id="id" value=''>
			<INPUT TYPE="hidden" NAME="index"   id="index" value=''>
			<TABLE >
			<TR>
					<TD >角色名称：</TD>
					<TD><INPUT TYPE="text" NAME="name" id="name"  value=''></TD>
			</TR>
			<TR>
					<TD >角色说明：</TD>
					<TD><INPUT TYPE="text" NAME="info" id="info"  value=''></TD>
			</TR>
			</TABLE>
		</FORM>
	</span>
</div>
<TABLE>
<TR>
	<TD>
		<div class="dtree">
			<script type="text/javascript">
				<!--
				mytree = new dTree('mytree');
		//		mytree.config.useRadio = true;  //设置有单选按钮isRoot?'<s:property value="menuName"/>[修改]': 
		//		mytree.config.useCheckbox = true; 
		 <s:iterator value="rb.resultList" id="m" status="cust_stat">    
				 mytree.add(<s:property value="ID"/>,<s:property value="PID"/>,'<s:property value="NAME"/>'+
				'[<A HREF="javascript:editNode(<s:property value="ID" />,<s:property value="PID"/>,\'<s:property value="NAME"/>\',\'<s:property value="INFO"/>\');" class="edit">修改</A>]'+
				<s:if test="#m.PID!=-1">'[<A HREF="javascript:delNode(<s:property value="ID" />,\'<s:property value="NAME"/>\');"  class="edit">删除</A>]' +</s:if>
				'[<A HREF="javascript:addNode(<s:property value="ID"/>);"  class="edit" title="增加子角色">增加</A>]'
				);	
			</s:iterator> 
				document.write(mytree);
				//-->
			</script>
		</div>
	</TD>
</TR>
</TABLE>
	
</body>
<SCRIPT LANGUAGE="JavaScript">


var onclickNode  = function(id){
	alert(id);
}

var checkData = function(){

	return true;
}

var _submit = function(){
	if($('#name').val()==''){
		alert("导航名称必须输入！");
	}else{
		$('#editDiv').dialog('close');
		wait.show();
		$('form:first').submit();
	}
}

var editNode = function(id,pid,name,info){	
	
	$('#editDiv').dialog('open');
	$('#id').val(id);
	$('#pid').val(pid);
	$('#name').val(name);
	$('#info').val(info);
	$('#index').val('editRole');
}

var delNode = function(id,name){
	if(confirm('确定删除【'+name+'】?')){
		$('#id').val(id);
		$('#name').val('delete');
		//$('form:first').attr('action','menu!delete.action');
		$('#index').val('deleteRole');
		_submit();
	}
}
var addNode = function(id){
	$('#editDiv').dialog('open');
	$('input').val('');
	$('#pid').val(id);
	$('#index').val('addRole');
}

</SCRIPT>